/**
 * 创建硬链接
 * 类似 shell 命令 ln source_file dest_file
*/

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(int argc, char **argv)
{

    if (argc < 3)
    {
        printf("Usage : %s <source_file> <dest_file1> ...\n", argv[0]);
    }

    int i = 2;
    for (; i < argc; ++i)
    {
        if(link(argv[1],argv[i]) != 0){
            perror("Link error: ");
            exit(EXIT_FAILURE);
        }
    }

    printf("Create Hard Link Done!\n");
    return 0;
}